package com.hhkj.study.admin.user.excel;

import cn.hutool.core.util.StrUtil;
import com.hhkj.study.admin.resource.excel.BaseExcelRes;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @Author luowu
 * @Date 2024/9/18 涵 16:28:39
 */
@Data
public class UserExcelRes extends BaseExcelRes {

    /**
     * 主键id
     */
    private Long id;

    /**
     * 姓名
     */
    @NotBlank(message = "姓名为空")
    @Excel(name = "姓名", width = 15, needMerge = true, require = true)
    private String name;
    /**
     * 密码
     */
    private String password;
    /**
     * 昵称
     */
    private String nickName;
    /**
     * 身份证号
     */
    @Excel(name = "身份证号", width = 15, needMerge = true)
    private String idCard;
    /**
     * 性别 0:未知 1:男 2:女
     */
    @Excel(name = "性别", width = 15, needMerge = true, readConverterExp = "0=未知,1=男,2=女", combo = {"男","女"})
    private Integer gender;
    /**
     * 注册来源 1.网站 2：视频号 3.抖音
     */
    private Integer registerSource;
    /**
     * 手机号码
     */
    @Length(min = 11, max = 11, message = "手机号码不合法")
    @Excel(name = "手机号码", width = 15, needMerge = true, require = true)
    private String mobile;
    /**
     * 所在省份,关联x_dict_multi_level表id
     */
    @Excel(name = "用户填写省份", width = 15, needMerge = true, customDictType = "regionCode", type = Excel.Type.EXPORT)
    private Long provinceId;

    /**
     * 所在城市,关联x_dict_multi_level表id
     */
    private Long cityId;

    /**
     * 实际工作区域,关联x_dict_multi_level表id
     */
    @Excel(name = "后台设置工作省份", width = 15, needMerge = true, customDictType = "regionCode")
    private Long realRegionId;

    /**
     * 职位
     */
    @Excel(name = "职位", width = 15, needMerge = true)
    private String post;
    /**
     * 学历
     */
    @Excel(name = "学历", width = 15, needMerge = true, combo = {"高中以下","高中", "本科", "硕士", "博士"})
    private String academic;
    /**
     * 工作年限
     */
    @Excel(name = "工作年限", width = 15, needMerge = true)
    private Integer workYears;
    /**
     * 毕业学校
     */
    @Excel(name = "所在行业", width = 15, needMerge = true)
    private String belongIndustry;
    /**
     * 所在行业
     */
    @Excel(name = "专业", width = 15, needMerge = true)
    private String schoolProfession;
    /**
     * 意向考试,关联x_intentional_exam中id
     */
    @Excel(name = "意向考试", width = 15, needMerge = true, customDictType = "courseTypeCode", combo = {"一级建造师", "二级建造师"})
    private Long intentionalExamId;

    /**
     * 常用邮箱
     */
    @Excel(name = "常用邮箱", width = 15, needMerge = true)
    private String email;

    @Excel(name = "备注", width = 15, needMerge = true)
    private String remark;

    /*@Excel(name = "购买课程数", width = 15, needMerge = true, type = Excel.Type.EXPORT)
    private Integer buyCourseCount;*/

    @Excel(name = "下单总金额", width = 15, needMerge = true, type = Excel.Type.EXPORT)
    private String orderTotalAmount;

    @Excel(name = "总订单数", width = 15, needMerge = true, type = Excel.Type.EXPORT)
    private Integer orderTotalCount;

    @Excel(name = "当月是否跟进", width = 15, needMerge = true, type = Excel.Type.EXPORT, readConverterExp = "0=否,1=是")
    private Integer currentMonthFollowFlag;

    @Excel(name = "最新跟进内容", width = 15, needMerge = true, type = Excel.Type.EXPORT)
    private String lastFollowContent;

    @Excel(name = "账号是否禁用", width = 15, needMerge = true, readConverterExp = "0=否,1=是", combo = {"是","否"})
    private Integer disableFlag;

    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
    private Date lastLoginTime;

    public String getPassword() {
        String newPassword = StrUtil.subSufByLength(this.mobile, 6);
        return SecurityUtils.encryptPassword(newPassword);
    }

    @Override
    public String getTitle() {
        return "学员导入模板\n" +
                "1、表头红色加粗为必填字段\n" +
                "2、省份只需选择xx省即可,如果是直辖市,就选择xx市\n" +
                "3、意向考试选项只需要选择一建/二建";
    }

    @Override
    public String getSheetName() {
        return "学员导入模板";
    }
}
